<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1">
  <title>VR试玩预约</title>
  <link rel="stylesheet" href="/assets/css/weixin/try_order.css" type="text/css" />
  <link rel="stylesheet" href="/assets/css/weixin/mobiscroll.custom-2.5.0.min.css" type="text/css" />
  <link rel="stylesheet" href="/assets/css/weixin/sweetalert.css">
</head>

<body style="overflow: hidden;">
  <div class="container">
    <div id="contact"> 
      <h3>预约小贝VR试玩</h3>
      <h4>小贝每周将从预约用户中随机抽取十名用户参与VR试玩</h4>
      <fieldset>
        <input placeholder="真实姓名" class="uname" type="text" tabindex="1" required autofocus>
      </fieldset>
      <fieldset>
        <input placeholder="常用邮箱" class="email" type="email" tabindex="2" required>
      </fieldset>
      <fieldset>
        <input placeholder="联系电话" class="mobile" type="tel" tabindex="3" required>
      </fieldset>
      <fieldset>
        <input placeholder="居住地址" class="address" type="text" tabindex="4" >
      </fieldset>
      <fieldset>
        <input id="datetime" name="datetime" class="try_date" placeholder="&nbsp;&nbsp;预约时间" tabindex="5" style="height:38px;" />
      </fieldset>
      <fieldset>
        <textarea placeholder="您的宝贵意见或留言" class="note" tabindex="6" required></textarea>
      </fieldset>
      <div style="text-align: center;" class="btn_submit">
        立即预约
      </div>
      <input type="hidden" class="uopenid" value="<?php echo $uopenid?>" />
    </div> 

</div>

<script type="text/javascript" src="/assets/js/jquery-2.1.0.min.js"></script>
<script type="text/javascript" src="/assets/js/jquery.mobile-1.3.0.min.js"></script>
<script type="text/javascript" src="/assets/js/mobiscroll.js"></script>
<script type="text/javascript" src="/assets/js/sweetalert.min.js"></script>
<script>
function null_check(val){
  if (val !== null || val !== undefined || val !== '') {
    return true;
  }else{
    return false;
  }
}

 $(function(){
  var h = $(window).height();
  $('body').css('height',h);
  var opt = {
        preset: 'date', //日期
        theme: 'bootstrap', //皮肤样式
        display: 'modal', //显示方式 
        mode: 'scroller', //日期选择模式
        dateFormat: 'yy-mm-dd', // 日期格式
        setText: '确定', //确认按钮名称
        cancelText: '取消',//取消按钮名籍我
        dateOrder: 'yymmdd', //面板中日期排列格式
        dayText: '日', monthText: '月', yearText: '年', //面板中年月日文字
    hourText: '时',minuteText: "分",ampmText:"上午/下午",
        endYear:2020 //结束年份
    };
    $("#date").mobiscroll().date(opt);
    $("#time").mobiscroll().time(opt);
    $("#datetime").mobiscroll().datetime(opt);

    $('.btn_submit').on('click',function(){
      var uname = $('.uname').val();
      var email = $('.email').val();
      var mobile = $('.mobile').val();
      var try_date = $('.try_date').val();
      var note = $('.note').val();
      var openid = $('.uopenid').val();
      var address = $('.address').val();
      $.ajax( {  
           url:'/home/try_order_add',// 跳转到 action  
           data:{  
                    openid:openid,
                    uname : uname,  
                    mobile : mobile,  
                    address : address,  
                    play_date : try_date,
                    type:0,
           },  
           type:'post',  
           cache:false,  
           dataType:'json',  
           success:function(data) {  
               if(data.code){  
                   swal('预约成功，中奖试玩名单将在微信公众号《VR小贝》内发送，敬请留意！');
               }else{
                  var msg = data.err_msg;
                  swal(msg);
               }  
            },  
            error : function() {  
              swal('系统繁忙，请稍后尝试！');
            }  
       });
      

      
    });
});



</script>
</body>

</html>